from zope.interface import implements, Interface

from Products.Five import BrowserView
from Products.CMFCore.utils import getToolByName
from zope.i18n.interfaces import ITranslationDomain
from zope.component import queryUtility

from my315ok.xtjxwcontents import xtjxwcontentsMessageFactory as _


class Ijiaolian_folderView(Interface):
    """
    jiaolian_folder view interface
    """

    def test():
        """ test method"""


class jiaolian_folderView(BrowserView):
    """
    jiaolian_folder browser view
    """
    implements(Ijiaolian_folderView)

    def __init__(self, context, request):
        self.context = context
        self.request = request

    @property
    def portal_catalog(self):
        return getToolByName(self.context, 'portal_catalog')

    @property
    def portal(self):
        return getToolByName(self.context, 'portal_url').getPortalObject()
    
    def translates(self,item):
#        import pdb
#        pdb.set_trace()      
        
        util = queryUtility(ITranslationDomain, 'my315ok.xtjxwcontents')    
        tted = util.translate(item,target_language="zh",
                                       default="xiangtanshihexi")           
        return tted
        
    def test(self,t,a,b):
        """ test method"""   
        if t:
            return a
        else:
            return b
